<template>
    <div>
        {{info}}
        <button @click="handleClick">Click</button>
        <br />
        {{info1}}
        <button @click="handleClick1">Server</button>
        <br />
        {{info2}}
        <button @click="login">Login</button>
        <br />
        {{info3}}
        <button @click="none">NONE</button>
    </div>
</template>
<script>
export default {
    data() {
        return {
            info: null,
            info1: null,
            info2: null,
            info3: null,
            baiduUrl: 'https://www.baidu.com',
            apiUrl: 'http://47.95.241.184:18080/c/t/t1',
            companyUrl: 'https://api.fjfruits.cn/dict/list',
            remoteUrl: 'https://api.fjfruits.cn/base/api/log/test',
            homeUrl: "https://api.fjfruits.cn/test",
            ipUrl: "https://api.fjfruits.cn/api/log/test",
            loginUrl: "https://api.fjfruits.cn/user/api/login/devops"
        }
    },
    methods: {
        handleClick: function() {
            this.$ajax({
                method: 'get',
                url: this.homeUrl,
                params: {
                    code: "1231313",
                    fileName: 'jdsfljaflsa.png'
                }
                // url: this.apiUrl,
                // url: this.baiduUrl
            }).then(res => (this.info = res.data))
        },
        handleClick1: function() {
            this.$ajax({
                method: 'get',
                url: this.remoteUrl,
                params: {
                    code: "1231313",
                    fileName: 'jdsfljaflsa.png'
                }
                // url: this.apiUrl,
                // url: this.baiduUrl
            }).then(res => (this.info1 = res.data))
        },
        login: function() {
            let params = {
                userName: "admin",
                userPwd: '123456'
            }
            // this.$ajax.post(this.loginUrl, params).then(res => (this.info2 = res.data));
            this.$ajax({
                headers:{
                    'Content-type': 'application/x-www-form-urlencoded'
                },
                transformRequest: [function (data) {
                    let ret = ''
                    for (let it in data) {
                        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                    }
                    return ret
                }],
                method: 'post',
                url: this.loginUrl,
                data: params
                // url: this.apiUrl,
                // url: this.baiduUrl
            }).then(res => (this.info2 = res.data))
        },
        none: function() {
            this.$ajax({
                method: 'get',
                url: this.companyUrl,
                // url: this.apiUrl,
                // url: this.baiduUrl
            }).then(res => (this.info3 = res.data))

        }
    }
}
</script>